import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import TestView from '../views/TestView'
import Login from '../views/login/index'
import Reg from '../views/login/reg'
import Forget from '../views/login/forget'
import ManageIndex from "@/views/manage/index";

const routes = [
  {
    path: '/',
    component: HomeView
  },
  {
    path: '/test',
    component: TestView
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/reg',
    component: Reg
  },
  {
    path: '/forgot',
    component: Forget
  },
  {
    path: '/manage_index',
    name: 'manage',
    component: ManageIndex
  },
  {
    path: '/manage',
    redirect: '/manage/userinfo',
    component: ManageIndex,
    meta: { title: '个人中心' },
    children: [
      {
        path: '/manage/userinfo',
        component: {
          manage: () => import('../views/manage/user/UserInfo')
        },
        meta: { title: '个人账户', requireAuth: true },
      },
      {
        path: '/manage/userpass',
        component: {
          manage: () => import('../views/manage/user/UserPass')
        },
        meta: { title: '修改密码', requireAuth: true },
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
